import numpy as np
import tensorflow.compat.v2 as tf
tf.enable_v2_behavior()
import pandas as pd
from tensorflow import keras
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import RobustScaler
from sklearn.preprocessing import MinMaxScaler
from matplotlib import pyplot
import plotly.graph_objects as go
import math
import seaborn as sns
from sklearn.metrics import mean_squared_error
np.random.seed(1)
tf.random.set_seed(1)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM, GRU, Dropout, RepeatVector, TimeDistributed
from keras import backend
MODELFILENAME = 'MODELS/GRU_6h_TFM_2c'
TIME_STEPS=36 #6h
CMODEL = GRU
MODEL = "GRU"
UNITS=45
DROPOUT1=0.118
DROPOUT2=0.243
ACTIVATION='tanh'
OPTIMIZER='adamax'
EPOCHS=43
BATCHSIZE=30
VALIDATIONSPLIT=0.2
# Code to read csv file into Colaboratory:
# from google.colab import files
# uploaded = files.upload()
# import io
# df = pd.read_csv(io.BytesIO(uploaded['SentDATA.csv']))
# Dataset is now stored in a Pandas Dataframe
df = pd.read_csv('../../data/dadesTFM.csv')
df.reset_index(inplace=True)
df['Time'] = pd.to_datetime(df['Time'])
df = df.set_index('Time')
columns = ['PM1','PM25','PM10','PM1ATM','PM25ATM','PM10ATM']
df1 = df.copy();
df1 = df1.rename(columns={"PM 1":"PM1","PM 2.5":"PM25","PM 10":"PM10","PM 1 ATM":"PM1ATM","PM 2.5 ATM":"PM25ATM","PM 10 ATM":"PM10ATM"})
df1['PM1'] = df['PM 1'].astype(np.float32)
df1['PM25'] = df['PM 2.5'].astype(np.float32)
df1['PM10'] = df['PM 10'].astype(np.float32)
df1['PM1ATM'] = df['PM 1 ATM'].astype(np.float32)
df1['PM25ATM'] = df['PM 2.5 ATM'].astype(np.float32)
df1['PM10ATM'] = df['PM 10 ATM'].astype(np.float32)
df2 = df1.copy()
train_size = int(len(df2) * 0.8)
test_size = len(df2) - train_size
train, test = df2.iloc[0:train_size], df2.iloc[train_size:len(df2)]
train.shape, test.shape
((3117, 7), (780, 7))
#Standardize the data
for col in columns:
scaler = StandardScaler()
train[col] = scaler.fit_transform(train[[col]])
<ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]])
def create_sequences(X, y, time_steps=TIME_STEPS):
Xs, ys = [], []
for i in range(len(X)-time_steps):
Xs.append(X.iloc[i:(i+time_steps)].values)
ys.append(y.iloc[i+time_steps])
return np.array(Xs), np.array(ys)
X_train, y_train = create_sequences(train[[columns[1]]], train[columns[1]])
#X_test, y_test = create_sequences(test[[columns[1]]], test[columns[1]])
print(f'X_train shape: {X_train.shape}')
print(f'y_train shape: {y_train.shape}')
X_train shape: (3081, 36, 1) y_train shape: (3081,)
#afegir nova mètrica
def rmse(y_true, y_pred):
return backend.sqrt(backend.mean(backend.square(y_pred - y_true), axis=-1))
model = Sequential()
model.add(CMODEL(units = UNITS, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))
model.add(Dropout(rate=DROPOUT1))
model.add(CMODEL(units = UNITS, return_sequences=True))
model.add(Dropout(rate=DROPOUT2))
model.add(TimeDistributed(Dense(1,kernel_initializer='normal',activation=ACTIVATION)))
model.compile(optimizer=OPTIMIZER, loss='mae',metrics=['mse',rmse])
model.summary()
Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= gru (GRU) (None, 36, 45) 6480 _________________________________________________________________ dropout (Dropout) (None, 36, 45) 0 _________________________________________________________________ gru_1 (GRU) (None, 36, 45) 12420 _________________________________________________________________ dropout_1 (Dropout) (None, 36, 45) 0 _________________________________________________________________ time_distributed (TimeDistri (None, 36, 1) 46 ================================================================= Total params: 18,946 Trainable params: 18,946 Non-trainable params: 0 _________________________________________________________________
history = model.fit(X_train, y_train, epochs=EPOCHS, batch_size=BATCHSIZE, validation_split=VALIDATIONSPLIT,
callbacks=[keras.callbacks.EarlyStopping(monitor='val_loss', patience=5, mode='min')], shuffle=False)
Epoch 1/43 83/83 [==============================] - 5s 63ms/step - loss: 0.6448 - mse: 0.7768 - rmse: 0.6636 - val_loss: 0.3413 - val_mse: 0.3121 - val_rmse: 0.3953 Epoch 2/43 83/83 [==============================] - 3s 39ms/step - loss: 0.5230 - mse: 0.5592 - rmse: 0.5702 - val_loss: 0.3245 - val_mse: 0.3004 - val_rmse: 0.3771 Epoch 3/43 83/83 [==============================] - 3s 35ms/step - loss: 0.5164 - mse: 0.5521 - rmse: 0.5643 - val_loss: 0.3172 - val_mse: 0.2944 - val_rmse: 0.3671 Epoch 4/43 83/83 [==============================] - 3s 40ms/step - loss: 0.5117 - mse: 0.5461 - rmse: 0.5606 - val_loss: 0.3125 - val_mse: 0.2908 - val_rmse: 0.3603 Epoch 5/43 83/83 [==============================] - 3s 34ms/step - loss: 0.5078 - mse: 0.5409 - rmse: 0.5574 - val_loss: 0.3082 - val_mse: 0.2879 - val_rmse: 0.3544 Epoch 6/43 83/83 [==============================] - 3s 39ms/step - loss: 0.5053 - mse: 0.5372 - rmse: 0.5554 - val_loss: 0.3053 - val_mse: 0.2859 - val_rmse: 0.3499 Epoch 7/43 83/83 [==============================] - 3s 38ms/step - loss: 0.5027 - mse: 0.5343 - rmse: 0.5532 - val_loss: 0.3028 - val_mse: 0.2843 - val_rmse: 0.3460 Epoch 8/43 83/83 [==============================] - 4s 45ms/step - loss: 0.5011 - mse: 0.5320 - rmse: 0.5521 - val_loss: 0.3009 - val_mse: 0.2831 - val_rmse: 0.3429 Epoch 9/43 83/83 [==============================] - 4s 43ms/step - loss: 0.4994 - mse: 0.5303 - rmse: 0.5507 - val_loss: 0.2996 - val_mse: 0.2823 - val_rmse: 0.3405 Epoch 10/43 83/83 [==============================] - 3s 40ms/step - loss: 0.4988 - mse: 0.5293 - rmse: 0.5503 - val_loss: 0.2976 - val_mse: 0.2813 - val_rmse: 0.3377 Epoch 11/43 83/83 [==============================] - 3s 40ms/step - loss: 0.4976 - mse: 0.5279 - rmse: 0.5492 - val_loss: 0.2974 - val_mse: 0.2809 - val_rmse: 0.3365 Epoch 12/43 83/83 [==============================] - 3s 40ms/step - loss: 0.4968 - mse: 0.5269 - rmse: 0.5486 - val_loss: 0.2956 - val_mse: 0.2801 - val_rmse: 0.3340 Epoch 13/43 83/83 [==============================] - 3s 38ms/step - loss: 0.4962 - mse: 0.5261 - rmse: 0.5480 - val_loss: 0.2945 - val_mse: 0.2794 - val_rmse: 0.3322 Epoch 14/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4956 - mse: 0.5253 - rmse: 0.5475 - val_loss: 0.2943 - val_mse: 0.2791 - val_rmse: 0.3312 Epoch 15/43 83/83 [==============================] - 3s 39ms/step - loss: 0.4949 - mse: 0.5245 - rmse: 0.5469 - val_loss: 0.2938 - val_mse: 0.2787 - val_rmse: 0.3301 Epoch 16/43 83/83 [==============================] - 3s 38ms/step - loss: 0.4944 - mse: 0.5240 - rmse: 0.5466 - val_loss: 0.2926 - val_mse: 0.2780 - val_rmse: 0.3283 Epoch 17/43 83/83 [==============================] - 4s 44ms/step - loss: 0.4939 - mse: 0.5232 - rmse: 0.5460 - val_loss: 0.2915 - val_mse: 0.2774 - val_rmse: 0.3266 Epoch 18/43 83/83 [==============================] - 4s 43ms/step - loss: 0.4934 - mse: 0.5226 - rmse: 0.5456 - val_loss: 0.2918 - val_mse: 0.2772 - val_rmse: 0.3263 Epoch 19/43 83/83 [==============================] - 3s 41ms/step - loss: 0.4933 - mse: 0.5221 - rmse: 0.5454 - val_loss: 0.2913 - val_mse: 0.2768 - val_rmse: 0.3254 Epoch 20/43 83/83 [==============================] - 3s 39ms/step - loss: 0.4924 - mse: 0.5214 - rmse: 0.5447 - val_loss: 0.2897 - val_mse: 0.2759 - val_rmse: 0.3233 Epoch 21/43 83/83 [==============================] - 3s 36ms/step - loss: 0.4922 - mse: 0.5212 - rmse: 0.5447 - val_loss: 0.2890 - val_mse: 0.2754 - val_rmse: 0.3223 Epoch 22/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4917 - mse: 0.5206 - rmse: 0.5441 - val_loss: 0.2886 - val_mse: 0.2749 - val_rmse: 0.3215 Epoch 23/43 83/83 [==============================] - 3s 36ms/step - loss: 0.4915 - mse: 0.5203 - rmse: 0.5439 - val_loss: 0.2882 - val_mse: 0.2746 - val_rmse: 0.3208 Epoch 24/43 83/83 [==============================] - 3s 38ms/step - loss: 0.4912 - mse: 0.5198 - rmse: 0.5436 - val_loss: 0.2879 - val_mse: 0.2742 - val_rmse: 0.3202 Epoch 25/43 83/83 [==============================] - 3s 41ms/step - loss: 0.4906 - mse: 0.5195 - rmse: 0.5430 - val_loss: 0.2867 - val_mse: 0.2735 - val_rmse: 0.3188 Epoch 26/43 83/83 [==============================] - 3s 40ms/step - loss: 0.4903 - mse: 0.5190 - rmse: 0.5430 - val_loss: 0.2863 - val_mse: 0.2732 - val_rmse: 0.3183 Epoch 27/43 83/83 [==============================] - 4s 48ms/step - loss: 0.4901 - mse: 0.5188 - rmse: 0.5429 - val_loss: 0.2858 - val_mse: 0.2730 - val_rmse: 0.3176 Epoch 28/43 83/83 [==============================] - 3s 36ms/step - loss: 0.4898 - mse: 0.5185 - rmse: 0.5428 - val_loss: 0.2848 - val_mse: 0.2726 - val_rmse: 0.3166 Epoch 29/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4897 - mse: 0.5182 - rmse: 0.5427 - val_loss: 0.2855 - val_mse: 0.2728 - val_rmse: 0.3172 Epoch 30/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4894 - mse: 0.5177 - rmse: 0.5426 - val_loss: 0.2851 - val_mse: 0.2726 - val_rmse: 0.3168 Epoch 31/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4893 - mse: 0.5179 - rmse: 0.5425 - val_loss: 0.2847 - val_mse: 0.2723 - val_rmse: 0.3163 Epoch 32/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4890 - mse: 0.5173 - rmse: 0.5425 - val_loss: 0.2840 - val_mse: 0.2721 - val_rmse: 0.3156 Epoch 33/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4888 - mse: 0.5174 - rmse: 0.5423 - val_loss: 0.2839 - val_mse: 0.2720 - val_rmse: 0.3154 Epoch 34/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4889 - mse: 0.5171 - rmse: 0.5424 - val_loss: 0.2843 - val_mse: 0.2721 - val_rmse: 0.3157 Epoch 35/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4886 - mse: 0.5167 - rmse: 0.5420 - val_loss: 0.2839 - val_mse: 0.2719 - val_rmse: 0.3153 Epoch 36/43 83/83 [==============================] - 3s 35ms/step - loss: 0.4883 - mse: 0.5164 - rmse: 0.5417 - val_loss: 0.2839 - val_mse: 0.2718 - val_rmse: 0.3151 Epoch 37/43 83/83 [==============================] - 3s 36ms/step - loss: 0.4883 - mse: 0.5162 - rmse: 0.5417 - val_loss: 0.2834 - val_mse: 0.2716 - val_rmse: 0.3147 Epoch 38/43 83/83 [==============================] - 3s 33ms/step - loss: 0.4881 - mse: 0.5164 - rmse: 0.5417 - val_loss: 0.2835 - val_mse: 0.2716 - val_rmse: 0.3147 Epoch 39/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4878 - mse: 0.5158 - rmse: 0.5412 - val_loss: 0.2832 - val_mse: 0.2714 - val_rmse: 0.3143 Epoch 40/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4880 - mse: 0.5162 - rmse: 0.5414 - val_loss: 0.2831 - val_mse: 0.2713 - val_rmse: 0.3142 Epoch 41/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4879 - mse: 0.5159 - rmse: 0.5412 - val_loss: 0.2828 - val_mse: 0.2712 - val_rmse: 0.3139 Epoch 42/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4877 - mse: 0.5161 - rmse: 0.5412 - val_loss: 0.2817 - val_mse: 0.2707 - val_rmse: 0.3127 Epoch 43/43 83/83 [==============================] - 3s 34ms/step - loss: 0.4875 - mse: 0.5156 - rmse: 0.5409 - val_loss: 0.2816 - val_mse: 0.2708 - val_rmse: 0.3126
import matplotlib.pyplot as plt
plt.plot(history.history['loss'], label='MAE Training loss')
plt.plot(history.history['val_loss'], label='MAE Validation loss')
plt.plot(history.history['mse'], label='MSE Training loss')
plt.plot(history.history['val_mse'], label='MSE Validation loss')
plt.plot(history.history['rmse'], label='RMSE Training loss')
plt.plot(history.history['val_rmse'], label='RMSE Validation loss')
plt.legend();
X_train_pred = model.predict(X_train, verbose=0)
train_mae_loss = np.mean(np.abs(X_train_pred - X_train), axis=1)
plt.hist(train_mae_loss, bins=50)
plt.xlabel('Train MAE loss')
plt.ylabel('Number of Samples');
def evaluate_prediction(predictions, actual, model_name):
errors = predictions - actual
mse = np.square(errors).mean()
rmse = np.sqrt(mse)
mae = np.abs(errors).mean()
print(model_name + ':')
print('Mean Absolute Error: {:.4f}'.format(mae))
print('Root Mean Square Error: {:.4f}'.format(rmse))
print('Mean Square Error: {:.4f}'.format(mse))
print('')
return mae,rmse,mse
mae,rmse,mse = evaluate_prediction(X_train_pred, X_train,MODEL)
GRU: Mean Absolute Error: 0.2106 Root Mean Square Error: 0.4448 Mean Square Error: 0.1979
model.save(MODELFILENAME+'.h5')
#càlcul del threshold de test
def calculate_threshold(X_test, X_test_pred):
distance = np.sqrt(np.mean(np.square(X_test_pred - X_test),axis=1))
"""Sorting the scores/diffs and using a 0.80 as cutoff value to pick the threshold"""
distance.sort();
cut_off = int(0.98 * len(distance));
threshold = distance[cut_off];
return threshold
for col in columns:
print ("####################### "+col +" ###########################")
#Standardize the test data
scaler = StandardScaler()
test_cpy = test.copy()
test[col] = scaler.fit_transform(test[[col]])
#creem seqüencia amb finestra temporal per les dades de test
X_test1, y_test1 = create_sequences(test[[col]], test[col])
print(f'Testing shape: {X_test1.shape}')
#evaluem el model
eval = model.evaluate(X_test1, y_test1)
print("evaluate: ",eval)
#predim el model
X_test1_pred = model.predict(X_test1, verbose=0)
evaluate_prediction(X_test1_pred, X_test1,MODEL)
#càlcul del mae_loss
test1_mae_loss = np.mean(np.abs(X_test1_pred - X_test1), axis=1)
test1_rmse_loss = np.sqrt(np.mean(np.square(X_test1_pred - X_test1),axis=1))
# reshaping test prediction
X_test1_predReshape = X_test1_pred.reshape((X_test1_pred.shape[0] * X_test1_pred.shape[1]), X_test1_pred.shape[2])
# reshaping test data
X_test1Reshape = X_test1.reshape((X_test1.shape[0] * X_test1.shape[1]), X_test1.shape[2])
threshold_test = calculate_threshold(X_test1Reshape,X_test1_predReshape)
test1_score_df = pd.DataFrame(test[TIME_STEPS:])
test1_score_df['loss'] = test1_rmse_loss.reshape((-1))
test1_score_df['threshold'] = threshold_test
test1_score_df['anomaly'] = test1_score_df['loss'] > test1_score_df['threshold']
test1_score_df[col] = test[TIME_STEPS:][col]
#gràfic test lost i threshold
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['loss'], name='Test loss'))
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['threshold'], name='Threshold'))
fig.update_layout(showlegend=True, title='Test loss vs. Threshold')
fig.show()
#Posem les anomalies en un array
anomalies1 = test1_score_df.loc[test1_score_df['anomaly'] == True]
anomalies1.shape
print('anomalies: ',anomalies1.shape); print();
#Gràfic dels punts i de les anomalíes amb els valors de dades transformades per verificar que la normalització que s'ha fet no distorssiona les dades
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=scaler.inverse_transform(test1_score_df[col]), name=col))
fig.add_trace(go.Scatter(x=anomalies1.index, y=scaler.inverse_transform(anomalies1[col]), mode='markers', name='Anomaly'))
fig.update_layout(showlegend=True, title='Detected anomalies')
fig.show()
print ("######################################################")
####################### PM1 ###########################
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy test[col] = scaler.fit_transform(test[[col]])
Testing shape: (744, 36, 1) 24/24 [==============================] - 0s 6ms/step - loss: 0.5597 - mse: 0.9860 - rmse: 0.6476: 0s - loss: 0.4149 - mse: 0.8819 - rmse: 0. evaluate: [0.5596691966056824, 0.9860188364982605, 0.6475839614868164] GRU: Mean Absolute Error: 0.1892 Root Mean Square Error: 0.5813 Mean Square Error: 0.3380
anomalies: (0, 10)
###################################################### ####################### PM25 ###########################
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Testing shape: (744, 36, 1) 24/24 [==============================] - 0s 7ms/step - loss: 0.5775 - mse: 0.9437 - rmse: 0.6663 evaluate: [0.5775355100631714, 0.9437271356582642, 0.666295051574707] GRU: Mean Absolute Error: 0.1984 Root Mean Square Error: 0.5340 Mean Square Error: 0.2852
anomalies: (0, 10)
###################################################### ####################### PM10 ###########################
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Testing shape: (744, 36, 1) 24/24 [==============================] - 0s 7ms/step - loss: 0.5915 - mse: 0.9272 - rmse: 0.6796 evaluate: [0.5914714336395264, 0.9271632432937622, 0.6796028017997742] GRU: Mean Absolute Error: 0.2077 Root Mean Square Error: 0.4925 Mean Square Error: 0.2426
anomalies: (0, 10)
###################################################### ####################### PM1ATM ########################### Testing shape: (744, 36, 1)
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
24/24 [==============================] - 0s 6ms/step - loss: 0.5973 - mse: 0.9509 - rmse: 0.6904 evaluate: [0.5972692966461182, 0.9508923888206482, 0.6904358267784119] GRU: Mean Absolute Error: 0.2030 Root Mean Square Error: 0.5011 Mean Square Error: 0.2511
anomalies: (0, 10)
###################################################### ####################### PM25ATM ###########################
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Testing shape: (744, 36, 1) 24/24 [==============================] - 0s 7ms/step - loss: 0.5930 - mse: 0.9539 - rmse: 0.6854 evaluate: [0.5930292010307312, 0.9538825154304504, 0.6853911280632019] GRU: Mean Absolute Error: 0.2019 Root Mean Square Error: 0.5129 Mean Square Error: 0.2631
anomalies: (0, 10)
###################################################### ####################### PM10ATM ###########################
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Testing shape: (744, 36, 1) 24/24 [==============================] - 0s 7ms/step - loss: 0.5873 - mse: 0.9246 - rmse: 0.6755 evaluate: [0.5873399376869202, 0.9246404767036438, 0.6754829287528992] GRU: Mean Absolute Error: 0.2060 Root Mean Square Error: 0.5164 Mean Square Error: 0.2666
anomalies: (0, 10)
######################################################